#pragma once
#include <string>
#include <ncnn/net.h>

namespace onechchy
{
	class MobileFaceNet
	{
	public:
		MobileFaceNet(const std::string& modelPath);
		~MobileFaceNet();

		void setThreadNum(int threadNum);
		ncnn::Mat preprocess(ncnn::Mat img, std::vector<int> info);
		void start(ncnn::Mat& ncnnImg, std::vector<float>& feature128);
		double calculSimilar(std::vector<float>& v1, std::vector<float>& v2, int distance_metric);
		bool loadResult();

	private:
		void getAffineMatrix(float* src_5pts, const float* dst_5pts, float* M);
		void warpAffineMatrix(ncnn::Mat src, ncnn::Mat& dst, float* M, int dstW, int dstH);
		void normalize(std::vector<float>& feature);

	private:
		ncnn::Net mMFaceNet;
		int mThreadNum = 1;
		bool mNetResult = false;
	};
}

